import 'dart:ui';

class MyAllGoods {
  static List<GoodModel> allGoodsList = [
    GoodModel(
      goodId: 1,
      goodName: 'Pet Cat No.1',
      marketPrice: 9999,
      price: 2000,
      localUrl: 'assets/images/goods/1.png',
      stock: 100,
      num: 0,
    ),
    GoodModel(
        goodId: 2,
        goodName: 'Pet Cat No.2',
        marketPrice: 9999,
        price: 188.8,
        num: 0,
        stock: 100,
        localUrl: 'assets/images/goods/2.png'),
    GoodModel(
        goodId: 3,
        marketPrice: 9999,
        goodName: 'Pet Cat No.3',
        price: 999,
        num: 0,
        stock: 100,
        localUrl: 'assets/images/goods/3.png'),
    GoodModel(
        goodId: 4,
        marketPrice: 9999,
        goodName: 'Pet Cat No.4',
        price: 100,
        num: 0,
        stock: 100,
        localUrl: 'assets/images/goods/4.png'),
    GoodModel(
        goodId: 5,
        marketPrice: 9999,
        goodName: 'Pet Cat No.5',
        num: 0,
        price: 50,
        stock: 100,
        localUrl: 'assets/images/goods/5.png'),
    GoodModel(
        goodId: 6,
        marketPrice: 9999,
        goodName: 'Pet Cat No.6',
        price: 77,
        num: 0,
        stock: 100,
        localUrl: 'assets/images/goods/6.png'),
    GoodModel(
        goodId: 7,
        goodName: 'Pet Cat No.7',
        marketPrice: 9999,
        price: 888,
        num: 0,
        stock: 100,
        localUrl: 'assets/images/goods/7.png'),
    GoodModel(
        goodId: 8,
        goodName: 'Pet Cat No.8',
        marketPrice: 9999,
        price: 1999,
        num: 0,
        stock: 100,
        localUrl: 'assets/images/goods/8.png'),
  ];
}
class MyColor{
  static Color mainColor = const Color(0xFFFFE3BB);
}
class UserModel {
  UserModel({
    this.password,
    this.userName,
  });

  String? userName;
  String? password;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['password'] = password;
    map['userName'] = userName;
    return map;
  }

  factory UserModel.fromJson(Map<String, dynamic> json) => UserModel()
    ..password = json['password'] as String?
    ..userName = json['userName'] as String?;
}

class GoodModel {
  GoodModel({
    this.goodName,
    this.goodId,
    this.price,
    this.localUrl,
    this.marketPrice,
    this.stock,
    this.num,
    this.isSelected,
  });

  int? goodId;
  String? goodName;
  String? localUrl;
  double? price;
  double? marketPrice;

  /// stock count
  int? stock;

  /// this num is the count of goods  in cart
  int? num;

  bool? isSelected;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['num'] = num;
    map['stock'] = stock;
    map['marketPrice'] = marketPrice;
    map['price'] = price;
    map['localUrl'] = localUrl;
    map['goodName'] = goodName;
    map['goodId'] = goodId;
    return map;
  }

  factory GoodModel.fromJson(Map<String, dynamic> json) => GoodModel()
    ..goodId = json['goodId'] as int?
    ..goodName = json['goodName'] as String?
    ..localUrl = json['localUrl'] as String?
    ..price = json['price'] as double?
    ..marketPrice = json['marketPrice'] as double?
    ..stock = json['stock'] as int?
    ..num = json['num'] as int?;
}

class OrderModel {
  OrderModel({
    this.orderId,
    this.totalPrice,
    this.orderNo,
    this.createTime,
    this.goodList,
  });

  int? orderId;
  double? totalPrice;
  String? orderNo;
  String? createTime;
  List<GoodModel>? goodList;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['goodList'] = goodList;
    map['createTime'] = createTime;
    map['orderNo'] = orderNo;
    map['totalPrice'] = totalPrice;
    map['orderId'] = orderId;
    return map;
  }

  factory OrderModel.fromJson(Map<String, dynamic> json) => OrderModel()
    ..orderId = json['orderId'] as int?
    ..totalPrice = json['totalPrice'] as double?
    ..orderNo = json['orderNo'] as String?
    ..createTime = json['createTime'] as String?
    ..goodList = (json['goodList'] as List<dynamic>?)
        ?.map(
            (dynamic item) => GoodModel.fromJson(item as Map<String, dynamic>))
        .toList();
}
